{% load helpers %}
{% if changelog and perms.extras.view_objectchange %}
    {% for change in changelog %}
        {% with action=change.get_action_display|lower %}
            <div class="list-group-item">
                {% if action == 'created' %}
                    <span class="badge bg-success me-4">Created</span>
                {% elif action == 'updated' %}
                    <span class="badge bg-warning me-4">Modified</span>
                {% elif action == 'deleted' %}
                    <span class="badge bg-danger me-4">Deleted</span>
                {% endif %}
                {{ change.changed_object_type.name|bettertitle }}
                {% if change and change.changed_object and change.changed_object.get_absolute_url %}
                    {{ change.changed_object|hyperlinked_object }}
                {% elif change and change.changed_object %}
                    {{ change.changed_object|default:change.object_repr }}
                {% elif change %}
                    {{ change.object_repr }}
                {% endif %}
                <br />
                <small>
                    <span class="text-secondary">{{ change.user_name }} -</span>
                    <a href="{{ change.get_absolute_url }}" class="text-secondary">{{ change.time|date:settings.SHORT_DATETIME_FORMAT }}</a>
                </small>
            </div>
        {% endwith %}
        {% if forloop.last %}
            <div class="list-group-item text-end">
                <a href="{% url 'extras:objectchange_list' %}">View All Changes</a>
            </div>
        {% endif %}
    {% endfor %}
{% elif perms.extras.view_objectchange %}
    <div class="card-body text-secondary">
        No change history found
    </div>
{% else %}
    <div class="card-body text-secondary">
        <span class="mdi mdi-lock" aria-hidden="true"></span> No permission
    </div>
{% endif %}
